<?php
include_once '../../include/dbconf.php';
function list_catlog(){
	global $db;
	$list=$db->get_results("select id,catlog_name,parent_id from catlog;",true);
	return $list;
}
function  get_catlog_list_by_id($id){
	global $db;
	$list=$db->get_results("select id,catlog_name,parent_id from catlog where id=$id",true);
	return $list;
}

/**
 *
 * Enter description here ...
 * @param   $id
 * @param   $parent_id
 * @param   $catlog_name
 */
function  catlog_update($id,$parent_id,$catlog_name){
	global $db;
	$sql="update  catlog   set parent_id=$parent_id, catlog_name='$catlog_name' where id=$id";
	 
	 
	$list=$db->query($sql,true);
	return $list>0;
}
/**
 * 
 * Enter description here ...
 * @param   $id
 * @param   $parent_id
 * @param   $catlog_name
 */
function  catlog_add($parent_id,$catlog_name){
	global $db;
	$sql="insert into  catlog(parent_id,catlog_name) values ($parent_id,'$catlog_name') ";
 	$list=$db->query($sql,true);
	return $list>0;
}

/**
 *delete catalog by id
 *
 * @param   $id
 */
function  catlog_delete($id){
	global $db;
	$list=$db->query("delete from catlog where id=$id",true);
	return $list>0;
}

function  get_catlog_list_by_parent_id($id){
	global $db;
	$list=$db->get_results("select id,catlog_name,parent_id from catlog where parent_id=$id ",true);
	return $list;
}
?>